import './edit_role.html';





Template.edit_role.events({
	'submit .role-edit'(event) {
	    event.preventDefault();

	   Meteor.call('roles.update', $("#edit_role_id").val(), 
	     	$("#edit_role_name").val(), $("#edit_role_weight").val(), 
	     	(error) => {
	      if (error) {
	        alert(error.error);
	      } else {
	        $('#edit-modal').modal('hide');
			FlashMessages.sendSuccess("角色更新成功");
	      }
	    });
	 },
	'show.bs.modal #edit-modal'(event, instance) {
		let role = Session.get("update_form");
		$("#edit_role_name").val(role.name);
	    $("#edit_role_weight").val(role.weight);
	    $("#edit_role_id").val(role._id);

	     
	}

});